package com.changgou.goods.feign;

import com.changgou.entity.Result;
import com.changgou.goods.pojo.Sku;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.List;

/**
 * @Author: HuangFu
 * @Date: 2020/2/1 12:03
 * @Description: Sku feign服务
 */
//声明feign客户端，连接goods服务
@FeignClient(name = "goods")
public interface SkuFeign {

    /**
     * 根据spuId查询sku
     * @param spuId
     * @return
     */
    @GetMapping("/sku/spu/{spuId}")
    List<Sku> findListBySpuId(@PathVariable("spuId") String spuId);

    /**
     * 查询Sku信息根据skuId
     * @param id
     * @return
     */
    @GetMapping("/sku/{id}")
    Result<Sku> findById(@PathVariable String id);

    /**
     * 库存数量变更
     * @param username
     */
    @PostMapping(value = "/sku/decr/count")
    void decrCount(@RequestParam("username")String username);

    /**
     * 库存回滚
     * @param skuId
     * @param num
     * @return
     */
    @PostMapping("/sku/resumeStockNum")
    Result resumeStockNum(@RequestParam("skuId") String skuId,@RequestParam("num") Integer num);


}
